export default {
    // 不能随便访问   
    namespaced: true,
    state: {
        name: "法外狂徒 彭于晏",
        age: 18,
        books: ["思想政治", "小鲤鱼历险记", "铁甲小宝"]
    },
    mutations: {
        handlerAge(state, payload) {
            console.log(payload)
            state.age += payload.num
        },
        handlerName(state, payload) {
            state.name = payload.name
        }
    },
    actions: {
        // 第一个参数 是ctx name  age  books
        // payload 
        asyncName(ctx, payload) {
            setTimeout(() => {
                ctx.commit("handlerName", payload)
            }, 3000)
        }
    },
    getters:{
        doubleAge(state) {
            return state.age * 2;
        },
    },
}